﻿using Coldairarrow.Business.Base_Company;
using Coldairarrow.Entity.Base_Company;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_Company
{
    [Route("/Base_Company/[controller]/[action]")]
    public class BTB_Company_VisitLogController : BaseApiController
    {
        #region DI

        public BTB_Company_VisitLogController(IBTB_Company_VisitLogBusiness bTB_Company_VisitLogBus)
        {
            _bTB_Company_VisitLogBus = bTB_Company_VisitLogBus;
        }

        IBTB_Company_VisitLogBusiness _bTB_Company_VisitLogBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<BTB_Company_VisitLog>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _bTB_Company_VisitLogBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<BTB_Company_VisitLog> GetTheData(IdInputDTO input)
        {
            return await _bTB_Company_VisitLogBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(BTB_Company_VisitLog data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _bTB_Company_VisitLogBus.AddDataAsync(data);
            }
            else
            {
                await _bTB_Company_VisitLogBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _bTB_Company_VisitLogBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}